package com.zfsn.okaria.intercept
import android.os.Bundle
import androidx.fragment.app.Fragment
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.elvishew.xlog.XLog
import com.zfsn.okaria.ARouteUtils
import com.zfsn.okaria.R
import com.zfsn.okaria.databinding.ActivityInterceptBinding
import com.zfsn.okaria.viewbinding.BaseActivity
@Route(path = ARouteUtils.route_intercept)
class InterceptActivity : BaseActivity<ActivityInterceptBinding>(ActivityInterceptBinding::inflate) {
    @Autowired(name = ARouteUtils.route_key_fragment)
    @JvmField
    var route_key_fragment: String? = null
    override fun initView(savedInstanceState: Bundle?) {
        super.initView(savedInstanceState)
        route_key_fragment?.let {
            convertPage(it, intent.extras)
        }
    }
    fun convertPage(routeFragment:String, bundle: Bundle? = null){
//        XLog.i("FMTransferActivity  ===>  convertPage routeFragment:$routeFragment")
        val tempFragment: Fragment = if (bundle != null) {
            ARouter.getInstance().build(routeFragment).with(bundle).navigation() as Fragment
        } else {
            ARouter.getInstance().build(routeFragment).navigation() as Fragment
        }
        supportFragmentManager.beginTransaction().replace(R.id.intercept_container, tempFragment).commit()
    }
}